home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
007a
/
899track.zip
/
899PICK.PRO
< prev
next >
Wrap
Text File
|
1990-03-06
|
9KB
|
220 lines
project "899"
include "899glob.pro"
% 899PICK.PRO -- Choices window for this system
% USES UNKNOWN NUMBER OF WINDOWS STARTING AT WINDOW NUMBER 30
% GLOBAL PREDICATES IN THIS FILE::
% show_get
DOMAINS
intlist = INTEGER*
DATABASE - wlib
wdef(INTEGER) % Window definition (nondeterm)
determ wcount(INTEGER) % A count of the number of windows
determ wsize(INTEGER,INTEGER,INTEGER,INTEGER) % Resulting window(s) size of Rows,Columns,Ent Rows,Ent Columns
determ wtit(STRING) % Common Title
edef(INTEGER,INTEGER,INTEGER,gs)
% The above is edef(WindowNumber,Xcoord,Ycoord,StringAtThatLocation)
PREDICATES
calcsize(INTEGER,INTEGER) % Calculate the seze of the windows given max size of an entity and number of entities
ars(INTEGER,INTEGER) % Given number of Row Entities, calculate the number of rows per window
calcwindows % Calculate the number of windows (size extracted)
asw(INTEGER,INTEGER) % Asserts the windoe definition (wdef) in the correct order
build_edef(gsList,INTEGER) % Buld the database edef definitions for all the given list (Number of windows extracted)
ef(gsList,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER) % Actually builds the edef.
build_windows % Make all the windows diplayable
disp_ents(INTEGER) % Does the diplaying of entities
dispell_info % Get rid of everything
memberI(INTEGER,intlist) % member on integers
chz1(INTEGER,INTEGER,INTEGER,INTEGER,gs)
chz2(key,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,gs)
pick_edit_dispatch(key,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER)
reg_title(STRING) % Registers title to display
CLAUSES
memberI(X,[X|_]).
memberI(X,[_|T]) :-
memberI(X,T).
show_get(ListIn,StrOut,TitleToShow) :- /* HERE IT IS!!!!!!! */
makewindow(OldWnum,_,_,_,_,_,_,_),
maxlen(ListIn,0,MaxStringLength), /* First get the longest string length */
listlen(ListIn,NumberOfItems), /* Then get the number of items */
calcsize(MaxStringLength,NumberOfItems),
calcwindows,
build_edef(ListIn,MaxStringLength),
reg_title(TitleToShow),
not(build_windows),
shiftwindow(30),
cursor(0,0),
StepX = 1, StepY = MaxStringLength + 1,
chz1(0,0,StepX,StepY,StrOut),
dispell_info,
shiftwindow(OldWnum). % And return to the calling window
calcsize(MaxStringLength,TotalEntCount) :-
((MaxStringLength+1) * 2) <= 78, !, % See if at least 2 can fit in largest window possible!!
% At this point we automatically choose the largest window possible and calcuate the rest
ColumnsOfEnts = 78 div (MaxStringLength+1),
RowsOfEnts = (TotalEntCount div ColumnsOfEnts) + 1,
ars(RowsOfEnts,RowsPerWindow), % Get the number of rows necesary for each window
ColumnsPerWindow = 80,
assert(wsize(RowsPerWindow,ColumnsPerWindow,RowsOfEnts,ColumnsOfEnts),wlib).
calcsize(MaxStringLength,TotalEntCount) :- % Here we can only have one column of entities
ColumnsOfEnts = 1,
ColumnsPerWindow = MaxStringLength+3,
RowsOfEnts = TotalEntCount,
ars(RowsOfEnts,RowsPerWindow),
assert(wsize(RowsPerWindow,ColumnsPerWindow,RowsOfEnts,ColumnsOfEnts),wlib).
ars(RowsOfEnts,RowsPerWindow) :-
RowsOfEnts < 23, !, % If Less than one screenfull then...
RowsPerWindow = RowsOfEnts+2.
ars(_,25). % Otherwise, max out the window to full screen
calcwindows :-
wsize(RowsPerWindow,_,RowsOfChoices,_),
RowsOfChoices <= (RowsPerWindow-2), !, % If RowsOfChoices is <= rowsPerWindow, then there is only one window
assert(wcount(1),wlib),
asw(30,30). % And just put this single window in our database
calcwindows :- % Here, we require more than one window to display all the choices
wsize(RowsPerWindow,_,RowsOfChoices,_),
NumberOfWindows = (RowsOfChoices div (RowsPerWindow-2)) + 1,
assert(wcount(NumberOfWindows),wlib), % Place the number of windows here
MaxWindowNumber = 30 + NumberOfWindows - 1,
asw(MaxWindowNumber,30).
asw(N,N) :- !, asserta(wdef(N),wlib).
asw(Curr,Ending) :-
asserta(wdef(Curr),wlib),
NewC = Curr - 1,
asw(NewC,Ending).
build_edef(ListOfEnts,MaxStringLength) :- % Build thew list
wsize(RowsPerWindow,_,_,ColumnsOfEnts), % Get this definition from database
FieldWidth = MaxStringLength + 1,
MaxRowNum = (RowsPerWindow-2) - 1, % 2 dor the frames and take in account the numbering scheme
ef(ListOfEnts,ColumnsOfEnts,0,0,0,MaxRowNum,30,FieldWidth). % Do it!!!
ef([],_,_,_,_,_,_,_) :- !. /* Finished building the definition */
ef([Str|L],EntCol,CurrEntCol,CurrY,CurrEntRow,MaxRow,CurrWindow,FieldWidth) :-
CurrEntCol < EntCol, !, % Make sure we don't go to far to the right logically
assert(edef(CurrWindow,CurrEntRow,CurrY,Str),wlib),
NewY = CurrY + FieldWidth,
NewEntCol = CurrEntCol + 1,
ef(L,EntCol,NewEntCol,NewY,CurrEntRow,MaxRow,CurrWindow,FieldWidth).
ef(Lister,EntCol,_,_,CurrEntRow,MaxRow,CurrWindow,FieldWidth) :-
% At this point, the y column has reached it's max, so we do the row increment
NewRow = CurrEntRow + 1,
NewRow <= MaxRow, !, % Make sure we don't go off the bottom of the window
NewY = 0, NewEntCol = 0,
ef(Lister,EntCol,NewEntCol,NewY,NewRow,MaxRow,CurrWindow,FieldWidth).
ef(Lister,EntCol,_,_,_,MaxRow,CurrWindow,FieldWidth) :-
% at this point we now increment the window numbers
NewWindow = CurrWindow + 1,
NewRow = 0,
NewEntCol = 0,
NewY = 0,
ef(Lister,EntCol,NewEntCol,NewY,NewRow,MaxRow,NewWindow,FieldWidth).
build_windows :- % This clause will fail
wcount(MaxPageCount),
str_int(MxStr,MaxPageCount), % Make a string of it
wtit(Temp1), % Get the Title part
Temp2 = " (Page ",
Temp3 = " of ",
Temp4 = ")",
wdef(Win), /* Grab a window definiton */
wsize(NumRows,NumColumns,_,_), /* And snag this */
CpageInt = Win - 29,
str_int(CurrPageNum,CpageInt),
fronttoken(K1,Temp1,Temp2), fronttoken(K2,K1,CurrPageNum),
fronttoken(K3,K2,Temp3), fronttoken(K4,K3,MxStr),
fronttoken(Title,K4,Temp4),
makewindow(Win,6,15,Title,0,0,NumRows,NumColumns,clear_window,center_title,single_line_frame),
disp_ents(Win).
disp_ents(CurW) :- % This clause will fail
edef(CurW,R,C,Str), % Grab a string definition
cursor(R,C),
write(Str),
fail.
dispell_info :-
wdef(Gimmie),
gotowindow(Gimmie),
removewindow,
fail.
dispell_info :- % Now kill all our database
retractall(_,wlib).
chz1(CurrX,CurrY,StepX,StepY,RetString) :-
makewindow(CurrW,Att,_,_,_,_,_,_),
getbacktrack(Btop),
edef(CurrW,CurrX,CurrY,StrHere),
cutbacktrack(Btop),
str_len(StrHere,Stlen),
inverse(Att,InvAtt),
field_attr(CurrX,CurrY,Stlen,InvAtt), % Set the attribute
getkey(Choice,[cr,esc,up,down,right,left,pgup,pgdn]),
field_attr(CurrX,CurrY,Stlen,Att), % Reset the attribute
pick_edit_dispatch(Choice,StepX,StepY,CurrW,CurrX,CurrY), % Do a dispatch
chz2(Choice,CurrX,CurrY,StepX,StepY,CurrW,RetString).
chz2(esc,_,_,_,_,_,"") :- !.
chz2(cr,CurrX,CurrY,_,_,CurrW,RetSpec) :- !,
edef(CurrW,CurrX,CurrY,RetSpec).
chz2(up,_,_,StepX,StepY,_,RetSpec) :- !,
cursor(NewX,NewY),
chz1(NewX,NewY,StepX,StepY,RetSpec).
chz2(down,_,_,StepX,StepY,_,RetSpec) :- !,
cursor(NewX,NewY),
chz1(NewX,NewY,StepX,StepY,RetSpec).
chz2(right,_,_,StepX,StepY,_,RetSpec) :- !,
cursor(NewX,NewY),
chz1(NewX,NewY,StepX,StepY,RetSpec).
chz2(left,_,_,StepX,StepY,_,RetSpec) :- !,
cursor(NewX,NewY),
chz1(NewX,NewY,StepX,StepY,RetSpec).
chz2(pgup,_,_,StepX,StepY,CurrW,RetSpec) :-
NewPage = CurrW - 1,
wdef(NewPage), /* May exist... may not */
!,
shiftwindow(NewPage), cursor(0,0),
chz1(0,0,StepX,StepY,RetSpec).
chz2(pgdn,_,_,StepX,StepY,CurrW,RetSpec) :-
NewPage = CurrW + 1,
wdef(NewPage), /* May Exist ... May not */
!,
shiftwindow(NewPage), cursor(0,0),
chz1(0,0,StepX,StepY,RetSpec).
chz2(_,CurrX,CurrY,StepX,StepY,_,RetSpec) :-
chz1(CurrX,CurrY,StepX,StepY,RetSpec).
pick_edit_dispatch(up,StepX,_,CurrW,CurrX,CurrY) :-
TargetX = CurrX - StepX,
edef(CurrW,TargetX,CurrY,_), !, /* If this exists, then move there */
cursor(TargetX,CurrY).
pick_edit_dispatch(down,StepX,_,CurrW,CurrX,CurrY) :-
TargetX = CurrX + StepX,
edef(CurrW,TargetX,CurrY,_), !, /* If this exists, then move */
cursor(TargetX,CurrY).
pick_edit_dispatch(right,_,StepY,CurrW,CurrX,CurrY) :-
TargetY = CurrY + StepY,
edef(CurrW,CurrX,TargetY,_), !,
cursor(CurrX,TargetY).
pick_edit_dispatch(left,_,StepY,CurrW,CurrX,CurrY) :-
TargetY = CurrY - StepY,
edef(CurrW,CurrX,TargetY,_), !,
cursor(CurrX,TargetY).
pick_edit_dispatch(_,_,_,_,_,_). /* Don't do anything */
reg_title("") :- !, % On a null string, use default title
assertz(wtit("Use cursors,\17\217 selects,ESC=EXIT"),wlib).
reg_title(NewTitle) :-
assertz(wtit(NewTitle),wlib).